package com.webmall.servlet.user;
/**
 * 用于注册界面id唯一性认真
 */

import com.webmall.service.webmall_UserDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/UserIdChecked")
public class UserIdChecked extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //设置字符集
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");

        //根据add界面的name参数进行内容获取
        String id = request.getParameter("id");

        int count = webmall_UserDao.countById(id);


        PrintWriter out = response.getWriter();
        //成功或失败重定位到哪儿
        if (count >0){

            out.print("false");

        }else {//失败 用输出流输出 js语句
            out.print("true");
        }


    }
}
